<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
$item=$this->plugin_setting('setting');
$return['adv']=$item['hdps'];
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_SESSION['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid'],'uid'=>$_SESSION['uid']);
	$fields=array('id','name','mobile','remark','status','createtime','pid');
    $orderby='createtime desc';
	$total='';
	$return['list']=pdo_getslice('jy_cmspinche_log',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$v){
		
		$v['createtime']=date('Y-m-d H:i:s',$v['createtime']);
		$v['time']=date('Y-m-d H:i:s',$v['time']);
		$p=pdo_get('jy_cmspinche_list',array('id'=>$v['pid']),array('title','start','end','time','type'));
		
		if($p['type']==1){
			$p['type']='拼车';
		}
		if($p['type']==2){
			$p['type']='带客';
		}
		$v=array_merge($v,$p);
	}
	
	exi($return);
	}
if($_RQ['op']=='cel'){
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择项目','error','yuding/');	
	}
	pdo_update('jy_cmspinche_log',array('stuatus'=>2),array('id'=>$id));
	exi('已拒绝','','yuding/');	
}
if($_RQ['op']=='ok'){
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择项目','error','yuding/');	
	}
	$item=pdo_get('jy_cmspinche_log',array('id'=>$id));
	$list=pdo_get('jy_cmspinche_list',array('id'=>$item['pid']));
	if($list['type']==1){
	pdo_update('jy_cmspinche_list',array('stuatus'=>3),array('id'=>$item['pid']));	
	pdo_update('jy_cmspinche_log',array('stuatus'=>1),array('id'=>$id));	
	}
	if($item['type']==2){
	if($list['num']==$item['num']){
	pdo_update('jy_cmspinche_list',array('stuatus'=>3,'num'=>0),array('id'=>$id));
	pdo_update('jy_cmspinche_log',array('stuatus'=>1),array('id'=>$id));	
	}elseif($list['num']>$item['num']){
		$num=$list['num'] - $item['num'];
	pdo_update('jy_cmspinche_list',array('num'=>$num),array('id'=>$id));
	pdo_update('jy_cmspinche_log',array('stuatus'=>1),array('id'=>$id));
	}else{
		exi('当前座位数小于乘客人数','error','home/');	
	}
	
	}
	exi('已确认','','home/');	
}
?>